Skip to content

feat: 添加名单表格搜索筛选功能#240

Open
trustedinster wants to merge 5 commits into
SECTL:masterfrom
trustedinster:fix/issue-232-list-search-filter
Open

feat: 添加名单表格搜索筛选功能#240
trustedinster wants to merge 5 commits into
SECTL:masterfrom
trustedinster:fix/issue-232-list-search-filter

Conversation

@trustedinster
Copy link
Copy Markdown
Contributor

概述

实现 #232 请求的功能:在查看名单时添加搜索/筛选功能。

变更内容

新增功能

  • 点名表格搜索栏:在点名表格卡片中添加搜索栏,支持按学号、姓名、性别、小组、标签进行关键词筛选
  • 抽奖表格搜索栏:在抽奖表格卡片中添加搜索栏,支持按序号、奖品、权重、标签、数量进行关键词筛选

技术实现

  • 使用 SearchLineEdit 组件(qfluentwidgets),与项目现有搜索组件风格一致
  • 搜索输入带 300ms 防抖处理,避免频繁刷新
  • 搜索匹配所有列的文本内容(不区分大小写)
  • 清空搜索框自动恢复显示所有行
  • 数据刷新后自动重新应用搜索过滤
  • 使用 ic_fluent_search_20_filled 图标,与 Fluent Design 风格一致

国际化

  • 添加中文、英文、日文三语翻译
  • 搜索栏标题和占位符文本均支持多语言

修改文件

  • app/view/settings/list_management/roll_call_table.py — 点名表格添加搜索功能
  • app/view/settings/list_management/lottery_table.py — 抽奖表格添加搜索功能
  • app/Language/modules/list_management.py — 添加搜索相关翻译

截图

搜索栏位于班级/奖池选择器下方、表格上方,输入关键词即可实时筛选。

Closes #232

在点名表格和抽奖表格中添加搜索栏,支持按关键词实时筛选表格行。

- 点名表格:支持按学号、姓名、性别、小组、标签筛选
- 抽奖表格:支持按序号、奖品、权重、标签、数量筛选
- 使用 SearchLineEdit 组件,带防抖处理(300ms)
- 添加中/英/日三语国际化翻译
- 刷新数据后自动重新应用搜索过滤

Closes SECTL#232
在点名历史记录和抽奖历史记录表格中添加导出按钮,
支持将当前表格数据导出为 xlsx、csv、txt 格式。

- 点名历史记录:支持导出全部记录、按时间查看、个人统计三种模式的数据
- 抽奖历史记录:支持导出全部记录、按时间查看、奖品统计三种模式的数据
- 导出内容与用户当前看到的表格一致(包括筛选和排序状态)
- 添加中/英/日三语国际化翻译
- 添加 QFileDialog 翻译配置

Closes SECTL#232
Comment on lines +1191 to +1197
export_type = (
"excel"
if "Excel 文件 (*.xlsx)" in selected_filter
else "csv"
if "CSV 文件 (*.csv)" in selected_filter
else "txt"
)

This comment was marked as outdated.

Comment on lines +1026 to +1032
export_type = (
"excel"
if "Excel 文件 (*.xlsx)" in selected_filter
else "csv"
if "CSV 文件 (*.csv)" in selected_filter
else "txt"
)

This comment was marked as outdated.

trustedinster and others added 2 commits May 16, 2026 09:22
修复非中文语言环境下导出格式判断失败的问题。
将 'Excel 文件 (*.xlsx)' 改为 '.xlsx' 匹配,
确保所有语言下都能正确识别导出格式。
Signed-off-by: Hongbro886 <hongbroyier@gmail.com>
Comment on lines +1117 to +1124
content=get_any_position_value_async(
"notification",
"lottery",
"export",
"content",
"error",
"name",
).format(message=str(e)),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The code calls .format() on the result of get_any_position_value_async without checking if it's None, causing a crash when a translation is missing for the user's language.
Severity: HIGH

Suggested Fix

Add a check to ensure the value returned from get_any_position_value_async is not None before calling .format() on it. Provide a default or fallback string if the translation is missing to prevent the crash. Additionally, add the missing "JA_JP" translations to the notification module in app/Language/modules/list_management.py to match the other modules.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: app/view/settings/history/lottery_history_table.py#L1117-L1124

Potential issue: The function `get_any_position_value_async` is used to retrieve
translation strings for notifications. It returns `None` if a translation for the
current language is not found. The code then calls the `.format()` method directly on
the return value of this function without a null check. The `notification` translation
module is missing the `"JA_JP"` (Japanese) language key. Consequently, when a user with
their language set to Japanese exports history, `get_any_position_value_async` returns
`None`, leading to an `AttributeError: 'NoneType' object has no attribute 'format'`.
This crash occurs in both the success and error handling paths, preventing the user from
seeing the export status notification.

Also affects:

  • app/view/settings/history/lottery_history_table.py:1093~1100
  • app/view/settings/history/roll_call_history_table.py:1283~1290
  • app/view/settings/history/roll_call_history_table.py:1259~1266

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

优化查看名单时的筛选按钮

2 participants